"""
@Project:p8_syl_flask
@File:__init__.py.py
@Author:郑凯乐
@Date:17:09
"""
from flask import Flask
from flask_cors import CORS
from common.models import db
from syl_project.users import user_bp
from  syl_project.oauth_user import oauth_user_bp
from syl_project.course import course_bp
from syl_project.comment import comment_bp
from syl_project.vip import vip_bp
from syl_project.pay import pay_bp
from common.utils.jwt_auth import jwt_authentication
def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    # 初始化数据库
    db.init_app(app)
    cors = CORS(app)

    # 钩子进行jwt 验证
    app.before_request(jwt_authentication)
    # 注册蓝图
    app.register_blueprint(user_bp)
    app.register_blueprint(oauth_user_bp)
    app.register_blueprint(course_bp)
    app.register_blueprint(comment_bp)
    app.register_blueprint(vip_bp)
    app.register_blueprint(pay_bp)


    return app
